<template>
  <div id="" class="i_login">
    <div class="title_logo">
      <img :src="tl" alt="" srcset="" />
    </div>
    <div class="uKeycalss" @click="uKeyBtn">下载u-key驱动</div>
    <div class="left_img" />
    <div class="login_content">
      <div class="logo">
        <img :src="lo" alt="" srcset="" />
      </div>
      <div class="title" style="display: inline-block">登录</div>
      <div style="display: inline-block; margin-left: 42px">
        <RadioGroup v-model="animal" @on-change='radioBtn'>
          <Radio label="0">加密锁</Radio>
          <Radio label="1">u-key</Radio>
        </RadioGroup>
      </div>
      <div class="info">
        <input
          type="text"
          disabled
          class="userLogin"
          placeholder="请输入用户名"
          v-model="loginInfo.username"
        />
        <input
          type="password"
          placeholder="请输入密码"
          v-model="loginInfo.password"
          @keydown.enter="enterToLogin"
        />
      </div>
      <div class="text-center corRed" id="messageId"></div>
      <div class="remember">
        <!-- <Checkbox v-model="single">记住密码</Checkbox> -->
      </div>
      <div class="but_group" @click="handleSubmit">
        <span> 登录 </span>
      </div>
    </div>
  </div>
</template>
<script>
import titleLogo from "@/assets/images/login/quanjilogo.png";
import logo from "@/assets/images/login/logo1.png";
import http from '@/api/http.js'
import iCopyright from "@/components/copyright";
import { mapActions } from "vuex";
import mixins from "../mixins";
var keyStr =
  "ABCDEFGHIJKLMNOP" +
  "QRSTUVWXYZabcdef" +
  "ghijklmnopqrstuv" +
  "wxyz0123456789+/" +
  "=";
export default {
  name: "",
  props: [""],
  data() {
    return {
      tl: titleLogo,
      lo: logo,
      single: false,
      autoLogin: true,
      loginInfo: {
        username: "",
        password: "",
      },
      animal: "0",
      scope: "",
      userNameStr: "",
      dogNotPresent: false,
      authCode:
        "AQAAAGomMAC71i/m3HWjBMg36JU2PUhiIrASe2hp9+rkdv84gtUE9CDh1DyoQ32Dp+JeeD9J7OojNdE8L35fKSsOQ0mFy+xk+s990USpA4sUKJ07L70Ph+fF6aofkTPEvjBj8kDYToo9bI/JejvZKoJDteYDcOeAK4xb5h+RsgwbN70mTWcSA8pJPSnCqllG4X/5kJQYBE1uca07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kUmDixrU3wFfXeBXCbDiGYhedoNsgmDwaj6wpj0MOjhuSZUqAD4ax0odFswTbxVJHi703NZZmLLXrvSsEBKs18fB4F84YzXq/jzXfUA7bNB6xNL38ANUnkqFLMFwNm4tFOCgdyAz4sjSgWeJXwdznZ8bUaRnJ0kHp8Q1InmyK1+D2olENGyNhvgTr4TwNv+q1ARMlZbCquQ6/ORv9KcBZK33tk8UPD2rNBKPCRSLPJxJ/jOogZjs3u/X4UzdXwwzqkhD3X9PTfNAk5Mh5nfYxZgX1/1SffAO3SyqJHXISvHlwL1j4kwTNA8z0eeJieQBa8PwY66aCwsLZAmGjzQfsasJFK7ZZtcMUvaotLBdMbDSma7/1pU/cAhF0x2dkGJO4Be44tqWaASXRGyr1IR9i+2rMmtYp9CO5yERZro/GekrgkylmAuWwlIjCo/A+UwsNMhsuDIEqYD0MdK2XZ/yYSJPc5hFUfjNq82yUyfkRelbgD0x4QjP54FiVgZ8Botu4ladsgEhNlrsFfMxI0MoY6EKS8PRSHqvtw7sMH0VeaRIP767mOMY5jcyezoKTZiOQhwX5J7bfdjYeyc0OV3BX99mqbyQHhmc4F2H9SOE35oX7N8nFgPnpSgPm3LQfeb7qMDSCbEaE0bh90BqdZ2YCi3lFSKBEtVsEaprPyTZ3OKN4SGKf43HaKf+hgGWc6KVA8wgy+M5VLRj3kdiuaIyxuL2FQTqfx1rrLswapnOKhVbn6IzraDJTPj9b65iuNq+MCJMBDj4vLC4TNzeSrLZLDe9iqzlQ==",
      time: null,
   };
  },
  mixins: [mixins],
  components: { iCopyright },
  computed: {},
  beforeMount() {},
  mounted() {
    this.time = setTimeout(() => {
      this.loadFunc();
    }, 1);   
  },
  created() {
    // this.setTime();
  },
  // beforeDestroy() {
  //   clearInterval(this.time);
  //   this.time = null;
  // },
  methods: {
    ...mapActions("admin/accountkey", ["login"]),
    // setTime() {
    //   this.time = setInterval(() => {
    //     this.loadFunc();
    //     // this.getUKeyUserName()
    //   }, 1750);
    // },
    loadFunc() {     
      var objAuth;
      let _this = this;
      objAuth = this.getAuthObject();
      if (navigator.userAgent.indexOf("Chrome") > 0) {
        setTimeout(this.checkDog, this.time);
        window.parent.addEventListener(
          "message",
          this.dogPassword,
          // function (event) {
          //   if (event.data.type == "SNTL_FROM_HOST") {
          //     var ReturnText = event.data.text;
          //     if (
          //       "GetUserNameEx" == ReturnText.InvokeMethod &&
          //       0 == ReturnText.Status && animal == '0'
          //     ) {
          //       _this.loginInfo.username = ReturnText.UserNameStr;
          //     } else {
          //       _this.loginInfo.username = "";
          //     }
          //   }
          // },
          false
        );
      } else {
        document.getElementById("messageId").innerHTML =
          "请用谷歌浏览器登陆系统！";
      }
    },
    radioBtn(val,name){
      this.time = 1752
      if (this.animal == '0') {        
        this.loadFunc()
      }
      this.loginInfo.username = "";
    },
    dogPassword(event){
      if (event.data.type == "SNTL_FROM_HOST") {
        var ReturnText = event.data.text;
        if (
          "GetUserNameEx" == ReturnText.InvokeMethod &&
          0 == ReturnText.Status && this.animal == '0'
        ) {
          this.loginInfo.username = ReturnText.UserNameStr;
        } else {
          this.loginInfo.username = "";
        }
      }
    },
    setUkey() {
      var httpRequest = new XMLHttpRequest();
      try {
        httpRequest.open("GET", window.config.ukeyService, false);
        httpRequest.send(null);
        var event = JSON.parse(httpRequest.responseText);
        if (event.code == 200 && event.data) {
          this.loginInfo.username = event.data;
        } else {
          this.loginInfo.username = "";
        }
      } catch (e) {
        this.loginInfo.username = "";
      }
    },
    checkDog() {      
      if (this.animal == "1") {
        window.removeEventListener('message', this.dogPassword, false);
        this.setUkey();
      } else {
        var stat = "";
        this.scope = "<dogscope/>";
        //Get object
        var objAuth = this.getAuthObject();
        if (navigator.userAgent.indexOf("Chrome") > 0) {
          objAuth.GetUserNameEx(this.scope, this.authCode);
        }
        //Execute the check again after 2 seconds
      }
      if (this.time) {
        setTimeout(this.checkDog, this.time);        
      }
    },
    getAuthObjectChrome() {
      // var obj = new AuthObject();
      var obj = this.AuthObject(new Object());
      return obj;
    },
    getAuthObject() {
      var objAuth;
      if (window.ActiveXObject || "ActiveXObject" in window) {
        //IE
        objAuth = document.getElementById("AuthIE");
      } else if (
        navigator.userAgent.indexOf("Chrome") > 0 ||
        navigator.userAgent.indexOf("Firefox") > 0
      ) {
        objAuth = this.getAuthObjectChrome();
      } else {
        objAuth = document.getElementById("AuthNoIE");
      }
      return objAuth;
    },
    AuthObject(AuthObject) {
      if (typeof AuthObject._initialized == "undefined") {
        let _this = this;
        // GetUserNameEx
        AuthObject.GetUserNameEx = function (scope, authCode) {
          //console.log("enter GetUserNameEx()");
          window.parent.postMessage(
            {
              type: "SNTL_FROM_PAGE",
              text: {
                InvokeMethod: "GetUserNameEx",
                Scope: scope,
                AuthCode: authCode,
              },
            },
            "*"
          );
          return 0;
        };

        // GetDigestEx
        AuthObject.GetDigestEx = function (
          scope,
          authCode,
          password,
          challenge
        ) {
          //console.log("enter GetDigestEx()");
          window.parent.postMessage(
            {
              type: "SNTL_FROM_PAGE",
              text: {
                InvokeMethod: "GetDigestEx",
                Scope: scope,
                AuthCode: authCode,
                UserPin: password,
                Challenge: challenge,
              },
            },
            "*"
          );
          return 0;
        };

        // RegisterUserEx
        AuthObject.RegisterUserEx = function (
          scope,
          authCode,
          username,
          password
        ) {
          //console.log("enter RegisterUserEx()");
          window.parent.postMessage(
            {
              type: "SNTL_FROM_PAGE",
              text: {
                InvokeMethod: "RegisterUserEx",
                Scope: scope,
                AuthCode: authCode,
                Name: username,
                UserPin: password,
              },
            },
            "*"
          );
          return 0;
        };

        // ChangeUserPinEx
        AuthObject.ChangeUserPinEx = function (
          scope,
          authCode,
          oldPassword,
          newPassword
        ) {
          //console.log("enter ChangeUserPinEx()");
          window.parent.postMessage(
            {
              type: "SNTL_FROM_PAGE",
              text: {
                InvokeMethod: "ChangeUserPinEx",
                Scope: scope,
                AuthCode: authCode,
                OldPin: oldPassword,
                NewPin: newPassword,
              },
            },
            "*"
          );
          return 0;
        };

        // SetUserDataEx
        AuthObject.SetUserDataEx = function (
          scope,
          authCode,
          password,
          type,
          offset,
          data
        ) {
          //console.log("enter SetUserDataEx()");
          window.parent.postMessage(
            {
              type: "SNTL_FROM_PAGE",
              text: {
                InvokeMethod: "SetUserDataEx",
                Scope: scope,
                AuthCode: authCode,
                UserPin: password,
                Type: type,
                Offset: offset,
                Data: data,
              },
            },
            "*"
          );
          return 0;
        };

        // GetUserDataEx
        AuthObject.GetUserDataEx = function (
          scope,
          authCode,
          type,
          offset,
          size
        ) {
          //console.log("enter GetUserDataEx()");
          window.parent.postMessage(
            {
              type: "SNTL_FROM_PAGE",
              text: {
                InvokeMethod: "GetUserDataEx",
                Scope: scope,
                AuthCode: authCode,
                Type: type,
                Offset: offset,
                Size: size,
              },
            },
            "*"
          );
          return 0;
        };

        // EnumDog
        AuthObject.EnumDog = function (authCode) {
          //console.log("enter EnumDog()");
          window.parent.postMessage(
            {
              type: "SNTL_FROM_PAGE",
              text: { InvokeMethod: "EnumDog", AuthCode: authCode },
            },
            "*"
          );
          return 0;
        };

        AuthObject._initialized = true;
        return AuthObject;
      }
    },
    enterToLogin(ev) {
      ev.keyCode === 13 && this.handleSubmit();
    },
    uKeyBtn(){
    // ,headers: {Authorization: icu.cookies.get('Authorization')}
      this.$Spin.show();
      http.$get('downloadUKey', {responseType: 'blob'}).then(res => {          
        this.$Spin.hide();
        const url = window.URL.createObjectURL(new Blob([res]));
        const link = document.createElement('a');
        link.href = url;
        link.setAttribute('download', 'u-key.zip');  // 设定下载文件名
        document.body.appendChild(link);
        link.click();
        link.remove();
      }).catch(err => {
        this.$Spin.hide();
      })
    },
    handleSubmit() {
      let { username, password } = this.loginInfo;
      if (username == "") {
        return this.$Message.warning("请插入加密锁！");
      }
      if (password == "") {
        return this.$Message.warning("请输入密码");
      }
      password = this.encode64(password);
      this.login({
        username,
        password,
        tyNames:'commodityLogin',
      }).then((data) => {
        this.time = null
        // 重定向对象不存在则返回顶层路径
        // this.$router.replace(this.$route.query.redirect || '/');
        if (data && data.code == 500) {
          if (data.msg) {
            return this.$Message.warning(data.msg);
          } else {
            return this.$Message.warning("用户名密码错误");
          }
        }        
        this.$router.replace("/root/home");
      });
    },
    encode64(input) {
      var output = "";
      var chr1,
        chr2,
        chr3 = "";
      var enc1,
        enc2,
        enc3,
        enc4 = "";
      var i = 0;
      do {
        chr1 = input.charCodeAt(i++);
        chr2 = input.charCodeAt(i++);
        chr3 = input.charCodeAt(i++);
        enc1 = chr1 >> 2;
        enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
        enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
        enc4 = chr3 & 63;
        if (isNaN(chr2)) {
          enc3 = enc4 = 64;
        } else if (isNaN(chr3)) {
          enc4 = 64;
        }
        output =
          output +
          keyStr.charAt(enc1) +
          keyStr.charAt(enc2) +
          keyStr.charAt(enc3) +
          keyStr.charAt(enc4);
        chr1 = chr2 = chr3 = "";
        enc1 = enc2 = enc3 = enc4 = "";
      } while (i < input.length);
      return output;
    },
  },
  watch: {},
};
</script>
<style lang='less' scoped>
.i_login {
  background: url("../../../assets/images/login/logninbg.png") no-repeat;
  background-size: 100% 100%;
  position: relative;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  .title_logo {
    position: absolute;
    left: 136px;
    top: 101px;
    img {
      width: 680px;
      height: 144px;
    }
  }
  .left_img {
    position: absolute;
    left: 0;
    bottom: 0px;
    background: url("../../../assets/images/login/left.png") no-repeat;
    background-size: 100% 100%;
    width: 1080px;
    height: 600px;
  }
  .login_content {
    position: absolute;
    background: #ffffff;
    width: 456px;
    height: 400px;
    background: #ffffff;
    box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.16);
    border-radius: 16px 16px 16px 16px;
    opacity: 1;
    right: 246px;
    top: 254px;
    padding: 20px 48px;
    .logo {
      width: 100%;
      display: flex;
      justify-content: end;
      align-items: center;
    }
    .title {
      font-size: 24px;
      font-family: PingFang SC-Bold, PingFang SC;
      font-weight: bold;
      color: #223893;
      height: 78px;
      line-height: 78px;
    }
    .info {
      display: flex;
      flex-direction: column;
      input {
        width: 360px;
        height: 48px;
        background: #ffffff;
        border-radius: 4px 4px 4px 4px;
        opacity: 1;
        border: 1px solid #e9ecf2;
        padding: 0 20px;
        color: #515a6e;
      }
      input:not(:first-child) {
        margin-top: 30px;
      }
      input:focus {
        outline: 1px solid #fff !important;
      }
      input::-webkit-input-placeholder {
        /* WebKit, Blink, Edge */
        color: #cccfd4;
        font-size: 16px;
      }
    }
    .but_group {
      cursor: pointer;
      width: 100%;
      height: 48px;
      background: #2d8cf0;
      border-radius: 4px 4px 4px 4px;
      opacity: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      span {
        font-size: 16px;
        font-family: PingFang SC-Bold, PingFang SC;
        font-weight: bold;
        color: #ffffff;
      }
    }
    .remember {
      // height: 58px;
      height: 28px;
      display: flex;
      align-items: center;
    }
  }
}
.userLogin {
  background: #ebebeb !important;
}
.corRed {
  text-align: center;
  margin-top: 24px;
  color: red;
}
.uKeycalss{
    color: #fff;
    font-size: 18px;
    position: absolute;
    top: 11%;
    right: 6%;    
    cursor: pointer;
}
</style>